<?php defined('SYSPATH') or die();?>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>思途CMS{$coreVersion}</title>
    {template 'stourtravel/public/public_js'}
    {php echo Common::getCss('style.css,base.css,base2.css,plist.css,base_new.css'); }
    {Common::css_plugin('financial-overview.css','finance')}
    {php echo Common::getScript("jquery-1.8.3.min.js,laydate/laydate.js"); }
</head>
<body>
<table class="content-tab">
    <tr>
        <td width="119px" class="content-lt-td" valign="top">
            {template 'stourtravel/public/leftnav'}
            <!--右侧内容区-->
        </td>
        <td valign="top" class="content-rt-td">
            <div class="cfg-header-bar">
                <a href="javascript:;" class="fr btn btn-primary radius mt-6 mr-10" onclick="window.location.reload()">刷新</a>
            </div>
            <div class="content-nrt" style="margin-top: 5px">
                <div class="clearfix ml-10">
                    <div class="ml-30 period-list clearfix fl date-switch">
                        <span data-day="7" class="period-item on">近7天</span>
                        <span data-day="14" class="period-item">近14天</span>
                        <span data-day="30" class="period-item">近30天</span>
                        <span data-day="-1" class="period-item">自定义</span>
                    </div>
                    <div class="date-range fl hide">
                        <span class="date-select">
                             <input type="text" class="input-text w200 start-date" placeholder="开始时间" />
                            <span class="item-text pl-5 pr-5 c-999">—</span>
                            <input type="text" class="input-text w200 end-date" placeholder="结束时间" />
                        </span>
                        <input class="btn radius btn-secondary size-S" type="button" onclick="get_statistics_data()" value="确定">
                    </div>
                </div>
                <!-- 筛选条件 -->

                <div class="financial-overview-block clearfix">

                    <div class="financial-overview-item income_statistics">
                        <div class="financial-overview-tit">收入统计</div>
                        <div class="financial-overview-con clearfix">
                            <div class="financial-item">
                                <div class="financial-tit">营业总收入(元)</div>
                                <div class="financial-num">{Currency_Tool::symbol()}<span class="num total_price">0.00</span></div>
                            </div>
                            <div class="financial-item">
                                <div class="financial-tit">已结算金额(元)</div>
                                <div class="financial-num">{Currency_Tool::symbol()}<span class="num finish_brokerage">0.00</span></div>
                            </div>
                            <div class="financial-item">
                                <div class="financial-tit">待结算金额(元)</div>
                                <div class="financial-num">{Currency_Tool::symbol()}<span class="num brokerage">0.00</span></div>
                            </div>
                            <div class="financial-item">
                                <div class="financial-tit">营收订单数(笔)</div>
                                <div class="financial-num"><span class="num total_num">0</span></div>
                            </div>
                            <div class="financial-item">
                                <div class="financial-tit">已到账订单数(笔)</div>
                                <div class="financial-num"><span class="num finish_brokerage_num">0</span></div>
                            </div>
                            <div class="financial-item">    
                                <div class="financial-tit">待审核订单数(笔)</div>
                                <div class="financial-num"><span class="num brokerage_num">0</span></div>
                            </div>
                        </div>
                        <div class="financial-overview-btn">
                            <a href="javascript:;" class="btn btn-primary-outline radius mr-20" onclick="jump_page(1)">对账明细</a>
                            <a href="javascript:;" class="btn btn-primary-outline radius" onclick="jump_page(2)">收入审核</a>
                        </div>
                    </div>
                    <!-- 收入统计 -->

                    <div class="financial-overview-item expenditure_statistics">
                        <div class="financial-overview-tit">支出统计</div>
                        <div class="financial-overview-con clearfix">
                            <div class="financial-item">
                                <div class="financial-tit">支出金额(元)</div>
                                <div class="financial-num">{Currency_Tool::symbol()}<span class="num total_price">0.00</span></div>
                            </div>
                            <div class="financial-item">
                                <div class="financial-tit">已提现金额(元)</div>
                                <div class="financial-num">{Currency_Tool::symbol()}<span class="num finish_brokerage">0.00</span></div>
                            </div>
                            <div class="financial-item">
                                <div class="financial-tit">待提现金额(元)</div>
                                <div class="financial-num">{Currency_Tool::symbol()}<span class="num brokerage">0.00</span></div>
                            </div>
                            <div class="financial-item">
                                <div class="financial-tit">总提现申请(笔)</div>
                                <div class="financial-num"><span class="num total_num">0</span></div>
                            </div>
                            <div class="financial-item">
                                <div class="financial-tit">已提现(笔)</div>
                                <div class="financial-num"><span class="num finish_brokerage_num">0</span></div>
                            </div>
                            <div class="financial-item">
                                <div class="financial-tit">待提现(笔)</div>
                                <div class="financial-num"><span class="num brokerage_num">0</span></div>
                            </div>
                        </div>
                        <div class="financial-overview-btn">
                            <a href="javascript:;" class="btn btn-primary-outline radius" onclick="jump_page(3)">会员提现</a>
                        </div>
                    </div>
                    <!-- 支出统计 -->

                </div>
                <!-- 平台 -->

                <div class="financial-overview-block clearfix">

                    <div class="financial-overview-item supplier_statistics">
                        <div class="financial-overview-tit">供应商账户</div>
                        <div class="financial-overview-con clearfix">
                            <div class="financial-item">
                                <div class="financial-tit">结算金额(元)</div>
                                <div class="financial-num">{Currency_Tool::symbol()}<span class="num total_price">0.00</span></div>
                            </div>
                            <div class="financial-item">
                                <div class="financial-tit">已结算金额(元)</div>
                                <div class="financial-num">{Currency_Tool::symbol()}<span class="num finish_brokerage">0.00</span></div>
                            </div>
                            <div class="financial-item">
                                <div class="financial-tit">待结算金额(元)</div>
                                <div class="financial-num">{Currency_Tool::symbol()}<span class="num brokerage">0.00</span></div>
                            </div>
                            <div class="financial-item">
                                <div class="financial-tit">总订单(笔)</div>
                                <div class="financial-num"><span class="num total_num">0</span></div>
                            </div>
                            <div class="financial-item">
                                <div class="financial-tit">已结算订单(笔)</div>
                                <div class="financial-num"><span class="num finish_brokerage_num">0</span></div>
                            </div>
                            <div class="financial-item">
                                <div class="financial-tit">待结算订单(笔)</div>
                                <div class="financial-num"><span class="num brokerage_num">0</span></div>
                            </div>
                        </div>
                        <div class="financial-overview-btn">
                            <a href="javascript:;" class="btn btn-primary-outline radius" onclick="jump_page(4)">供应商结算</a>
                        </div>
                    </div>
                    <!-- 供应商账户 -->

                    {if St_Functions::is_normal_app_install('mobiledistribution')}
                    <div class="financial-overview-item fenxiao_statistics">
                        <div class="financial-overview-tit">分销商账户</div>
                        <div class="financial-overview-con clearfix">
                            <div class="financial-item">
                                <div class="financial-tit">分销佣金(元)</div>
                                <div class="financial-num">{Currency_Tool::symbol()}<span class="num total_price">0.00</span></div>
                            </div>
                            <div class="financial-item">
                                <div class="financial-tit">已结算佣金(元)</div>
                                <div class="financial-num">{Currency_Tool::symbol()}<span class="num finish_brokerage">0.00</span></div>
                            </div>
                            <div class="financial-item">
                                <div class="financial-tit">待结算佣金(元)</div>
                                <div class="financial-num">{Currency_Tool::symbol()}<span class="num brokerage">0.00</span></div>
                            </div>
                            <div class="financial-item">
                                <div class="financial-tit">总结算(笔)</div>
                                <div class="financial-num"><span class="num total_num">0</span></div>
                            </div>
                            <div class="financial-item">
                                <div class="financial-tit">已结算(笔)</div>
                                <div class="financial-num"><span class="num finish_brokerage_num">0</span></div>
                            </div>
                            <div class="financial-item">
                                <div class="financial-tit">待结算(笔)</div>
                                <div class="financial-num"><span class="num brokerage_num">0</span></div>
                            </div>
                        </div>
                        <div class="financial-overview-btn">
                            <a href="javascript:;" class="btn btn-primary-outline radius" onclick="jump_page(5)">分销商结算</a>
                        </div>
                    </div>
                    <!-- 分销商账户 -->
                    {/if}

                </div>
            </div>
        </td>
    </tr>
</table>
<script>
    function jump_page(type)
    {
        var url = SITEURL;
        var title = '';
        if(type===1){
            title = '对账明细';
            url += 'finance/admin/finance/record/check/index/menuid/'+"{$menu_id[1]}";
        }else if(type===2){
            title = '收入审核';
            url += 'finance/admin/finance/income/aduit/menuid/'+"{$menu_id[2]}";
        }else if(type===3){
            title = '会员提现';
            url += 'finance/admin/finance/member/withdraw/aduit/menuid/'+"{$menu_id[3]}";
        }else if(type===4){
            title = '供应商结算';
            url += 'finance/admin/finance/supplier/settle/aduit/menuid/'+"{$menu_id[4]}";
        }else{
            title = '会员结算';
            url += 'finance/admin/finance/fenxiao/index/commission/menuid/'+"{$menu_id[5]}";
        }
        parent.window.addTab(title,url,1);
    }

    $(function(){
        get_statistics_data();
        laydate.render({
            elem: '.date-select'
            //设置开始日期、日期日期的 input 选择器
            //数组格式为 5.3.0 开始新增，之前版本直接配置 true 或任意分割字符即可
            ,range: ['.start-date', '.end-date']
        });
        $('.date-switch span').on('click',function(){
            $(this).addClass('on').siblings().removeClass('on');
            var day = $(this).attr('data-day');
            if(day==='-1'){
                $('.date-range').removeClass('hide');
            }else{
                $('.date-range').addClass('hide');
                get_statistics_data();
            }
        });
    })

    function get_statistics_data()
    {
        var day = $('.date-switch .on').attr('data-day');
        var start_date = $('.start-date').val();
        var end_date = $('.end-date').val();
        if(day==='-1' && !start_date && !end_date){
            ST.Util.showMsg('请选择时间',5);
            return false;
        }
        $.ajax({
            url: SITEURL + 'finance/admin/finance/income/ajax_get_statistics_data',
            dataType: 'json',
            type: 'post',
            data: {
                day: day,
                start_date: start_date,
                end_date: end_date
            },
            success: function (res) {
                if(res.status){
                    statistics_data('income_statistics',res.data.income_statistics);
                    statistics_data('expenditure_statistics',res.data.expenditure_statistics);
                    statistics_data('supplier_statistics',res.data.supplier_statistics);
                    statistics_data('fenxiao_statistics',res.data.fenxiao_statistics);
                }else{
                    ST.Util.showMsg(res.msg,5);
                }
            }
        })
    }

    function statistics_data(class_name,data)
    {
        $('.'+class_name+' .total_price').text(data.total_price);
        $('.'+class_name+' .finish_brokerage').text(data.finish_brokerage);
        $('.'+class_name+' .brokerage').text(data.brokerage);
        $('.'+class_name+' .total_num').text(data.total_num);
        $('.'+class_name+' .finish_brokerage_num').text(data.finish_brokerage_num);
        $('.'+class_name+' .brokerage_num').text(data.brokerage_num);
    }
</script>

</body>
</html>
